<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: products_images.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

defined('_VALID_XTC') or die('Direct Access to this location is not allowed.');

$languages = get_languages(); ?>

<div class="header"><?php echo TEXT_PRODUCTS_MAIN_IMAGE ?></div>
<?php if(!empty($pInfo->products_id)) { ?>
	<script type="text/javascript">
		function uploadFirst() {
			$('#product_image').html('<div id="first_upload_button"><table width="100%"><tr><td width="1" valign="top" height="40px"><input class="css_img_button" id="main_image" type="file" name="main_image" style="margin-right:15px" /></td><td><div id="img_queue"></div></td></tr></table></div>');
			$('#main_image').uploadify({
				'uploader'  : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/uploadify.swf',
				'script'    : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/uploadify.php',
				'cancelImg' : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/cancel.png',
				'folder'    : '<?php echo DIR_WS_CATALOG_ORIGINAL_IMAGES ?>',
				'buttonText': 'Grafik suchen',
				'auto':true,
				'wmode': 'transparent',
				'queueID':'img_queue',
				'onComplete' : function(event, ID, fileObj, response, data){xajax_generateImages(fileObj.name, <?php echo $pInfo->products_id ?>);msg('success','Erfolgreich gespeichert','Das Produktbild wurde erfolgreich gespeichert');}
			});
		}
	
		function msg(type, titleText, msgText) {
			$.gritter.add({title: titleText,text:msgText,image:'<?php echo DIR_WS_ICONS; ?>dialog-'+type+'.png',sticky:false,time: 3500});
		}
	
		function ask(message, name, id, nr) {
			if(nr){var inr = nr;}else{var inr ='';}
		    var answer = confirm(message);
		    if (answer){xajax_deleteImage(name,id,inr);}
		    return false;  
		}
	</script>
	<div id="product_image"></div><br />
	
	<script type="text/javascript">
		$(function(){
			$('#more_images').uploadify({
				'uploader'  : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/uploadify.swf',
				'script'    : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/uploadify.php',
				'cancelImg' : '<?php echo DIR_WS_ADMIN ?>includes/javascript/upload/cancel.png',
				'folder'    : '<?php echo DIR_WS_CATALOG_ORIGINAL_IMAGES ?>',
				'buttonText': 'Bild hochladen',
				'auto':true,
				'wmode': 'transparent',
				'queueID' : 'more_img_queue',
				'onComplete' : function(event, ID, fileObj, response, data){xajax_generateMoreImages(fileObj.name, <?php echo $pInfo->products_id ?>);}
			});
		});
	</script>
	<div class="header"><?php echo TEXT_PRODUCTS_IMAGE ?></div>
	<table width="100%">
		<tr>
			<td width="1" valign="top" height="40px"><input class="css_img_button" id="more_images" type="file" name="more_images" style="margin-right:15px" /></td>
			<td><div id="more_img_queue"></div></td>
		</tr>
	</table>
	<div id="products_images">
		<?php
			$img = $db->db_query("SELECT 
										image_name, 
										image_nr 
									FROM 
										".TABLE_PRODUCTS_IMAGES." 
									WHERE 
										products_id = ".$db->db_prepare($pInfo->products_id)."
									ORDER BY
										image_nr ASC");
			if ($img->_numOfRows) {
				while(!$img->EOF) {
					$languages = get_languages();
					echo '	<div id="pi_'.$pInfo->products_id.'_'.$img->fields['image_nr'].'" style="margin-bottom:10px">
								<table width="100%">
									<tr>
										<td align="left" class="main" width="'.(PRODUCT_IMAGE_THUMBNAIL_WIDTH + 15).'">
											'.image(DIR_WS_CATALOG_THUMBNAIL_IMAGES.$img->fields['image_name'], 'Standard Image').'
										</td>
										
										<td class="main">
											<b>'.$img->fields['image_name'].'</b><br />
											<a href="javascript:void(0)" class="button" onclick="return ask(\''.ASK_CONFIRM_DELETE_IMAGE.'\', \''.$img->fields['image_name'].'\','.$pInfo->products_id.','.$img->fields['image_nr'].')">'.TEXT_DELETE.'</a><br /><br />
											Alternativtext:<br />';
											for($i = 0, $n = sizeof($languages); $i < $n; $i++) {
												echo '	<nobr>
															'.image(DIR_WS_LANGUAGES . $languages[$i]['directory'] .'/'. $languages[$i]['image'], $languages[$i]['name']).' '.draw_input_field('products_image_alt_'.$languages[$i]['id'], get_img_alt((int)$pInfo->products_id, $languages[$i]['id']), 'style="width:90%"').'
														</nobr><br />';
											}
					echo 		'		</td>
									</tr>
								</table>
							</div>';
					$img->MoveNext();
				}
			}
		?>
	</div>
<?php } else echo 'Bitte klicken Sie auf "Übernehmen" um die Bildzuordnung zu ermöglichen.'; ?>